#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <getopt.h>

#define BUFLEN 4096
 
int main(int argc,char **argv)
{
    /* Length of the password */
    unsigned short int length = 8;
    long dumpLen;
    long i;

    char *sbuf;

    int opt,minc,maxc;

    minc=8;
    maxc=64;

   if(argc < 2 ) { printf("usage: %s -n num_of_str -m min_str_len -x max_str_len\n",argv[0]); exit(-1); }
	     
	while ((opt = getopt(argc, argv, "m:n:x:")) != -1) {
		switch (opt) {
		case 'm':
			minc = atol(optarg);
			break;
		case 'x':
			maxc = atol(optarg);
            		if(maxc>BUFLEN) maxc=BUFLEN;
			break;
		case 'n':
		    dumpLen = atol(optarg);	
            break;
        default:
            break;
         }
     }


    /* Seed number for rand() */
    srand((unsigned int) time(0) + getpid());

    /* ASCII characters 33 to 126 */
    sbuf = (char *) calloc(BUFLEN,sizeof(char)); 
    for( i = 0L ; i< dumpLen; i++) { 
	length = (int)(rand() % maxc + minc );

    while(length--) {
            sbuf[length] = (char)(rand() % 75 + 48);
            fprintf(stderr,"%s",sbuf);
         //   srand(rand());
        }
     
    printf("\n");
    memset(sbuf,0x0,BUFLEN);

   }
	 
    return EXIT_SUCCESS;
}

